<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
</head>

<body>
    <script>
        /*    let p1 = $.ajax({
               url: './data/1.json',
               success([res]) {
                   console.log(res)
               }
           })
               .then(res => {
                   console.log(res)
               }) */


        let myPromise = (url) => $.ajax({ url: url })
        myPromise('./data/1.json')
            .then((res) => {
                console.log(res)
                return res.count >= 0 ? myPromise('./data/2.json') : ''
            })
            .then((res2) => {
                console.log(res2);
                return res2.count >= 1 ? myPromise('./data/2.json') : ''
            })
            .then((res3) => {
                console.log(res3)
            })
    </script>
</body>

</html>